home *** CD-ROM | disk | FTP | other *** search
/ Aminet 28 / Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso / Aminet / dev / src / GLperf3.12-src.lha / GLperf / EnvAOS.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-09-19  |  32.6 KB  |  1,057 lines

  1. #include <stdio.h>
  2. #include <ctype.h>
  3. #include <string.h>
  4. #include <errno.h>
  5. #include <time.h>
  6. #include <math.h>
  7. #include "Env.h"
  8. #include <malloc.h>
  9. #include <gl/glaux.h>
  10.  
  11. static char *GetShortVendorName(char *input);
  12. static int GetHostMemorySize(void);
  13. static char *GetHostVendor(void);
  14. static char *GetHostModel(void);
  15. static char *GetHostCPU(void);
  16. static char *GetHostOperatingSystem(void);
  17. static char *GetHostOperatingSystemRelease(void);
  18. static char *GetHostName(void);
  19. static char *GetOpenGLClientVendor(void);
  20. static char *GetOpenGLClientVersion(void);
  21. static char *GetOpenGLClientExtensions(void);
  22. static char *GetHostCPUCount(void);
  23. static char *GetHostPrimaryCacheSize(void);
  24. static char *GetHostSecondaryCacheSize(void);
  25. static char *GetWindowSystem(void);
  26. static char *GetDriverVersion(void);
  27.  
  28.  
  29. /******************************************************************************
  30.  *
  31.  * StringSearch - search for pattern in string
  32.  *
  33.  * Description:
  34.  *  StringSearch returns a pointer to the first occurance of pattern found in
  35.  *  the subject or NULL if the pattern is not found. It implements the
  36.  *  Knuth-Morris-Pratt pattern matching algorithm. If m is the length of the
  37.  *  pattern and n is the length of the subject, the complexity of the KMP
  38.  *  algorithm is (m+n), much better than the (m*n) complexity of the naive
  39.  *  nested loop algorithm. - John Dennis
  40.  *
  41.  * Returns:
  42.  *  pointer to the first occurance of pattern found the subject or NULL
  43.  *
  44.  * Side Effects:
  45.  *  None
  46.  *
  47.  * Errors:
  48.  *  None
  49.  *
  50.  * Revision History:
  51.  *  Revision 0: Author: John R. Dennis Date: Thu Aug  4 15:49:59 1994
  52.  *    Initial Release
  53.  *
  54.  *****************************************************************************/
  55. char *
  56. StringSearch(char *subject, char *pattern)
  57. {
  58. #define MAX_FLINK (256)
  59.   int *flink, *dynamicFlink = NULL, staticFlink[MAX_FLINK];
  60.   int patternLen = strlen(pattern);
  61.   int subjectLen = strlen(subject);
  62.   int found = 0;
  63.   int i,j;
  64.  
  65.   if (patternLen > MAX_FLINK) {      /* -1 for NULL terminator */
  66.     dynamicFlink = malloc(patternLen * sizeof(int));
  67.     if (dynamicFlink == NULL) {
  68.       fprintf(stderr, "malloc failure, line %d, file: %s, exiting...\n",
  69.           __LINE__, __FILE__);
  70.       exit(1);
  71.     }
  72.     flink = dynamicFlink;
  73.   }
  74.   else {
  75.     flink = staticFlink;
  76.   }
  77.  
  78.  
  79.   /* Step 1: Constuct Flowchart */
  80.   flink[0] = -1;               /* -1 == read next char */
  81.   for(i = 1; i < patternLen; i++) {
  82.     j = flink[i-1];
  83.     while((j >= 0) && (pattern[j] != pattern[i-1])) {
  84.       j = flink[j];
  85.     }
  86.     flink[i] = j+1;
  87.   }
  88.  
  89.   /* Step 2: Scan Algorithm */
  90.   for (i = j = 0; i < subjectLen; i++, j++) {
  91.     while((j >= 0) && (pattern[j] != subject[i])) {
  92.       j = flink[j];
  93.     }
  94.     if (j == patternLen-1) {
  95.       found = 1;
  96.       goto exit;
  97.     }
  98.   }
  99.  
  100.  exit:
  101.   if (dynamicFlink != NULL) free(dynamicFlink);
  102.   if (!found)
  103.     return(NULL);
  104.   else
  105.     return(&subject[i-patternLen+1]);
  106. #undef MAX_FLINK
  107. }
  108.  
  109.  
  110. /******************************************************************************
  111.  *
  112.  * GetShortVendorName - return short vendor string
  113.  *
  114.  * Description:
  115.  *  some vendor strings are verbose. This function will return a shortest
  116.  *  vendor name it can given an arbitrary vendor string. The returned string
  117.  *  is allocated with malloc, it should be freed when no longer in use. The
  118.  *  input string is not freed or modified by this function.
  119.  *
  120.  * Returns:
  121.  *  pointer to allocated string
  122.  *
  123.  * Side Effects:
  124.  *  string allocation, string should be freed when no longer needed.
  125.  *
  126.  * Errors:
  127.  *  no errors, if function fails the string "unknown" is returned
  128.  *
  129.  * Revision History:
  130.  *  Revision 0: Author: John R. Dennis Date: Mon Aug  8 16:30:53 1994
  131.  *    Initial Release
  132.  *
  133.  *****************************************************************************/
  134. static char *
  135. GetShortVendorName(char *input)
  136. {
  137.   int i;
  138.   char *s1 = NULL;              /* s1 is temp work string */
  139.   char *s2 = NULL;              /* s2 is string to return */
  140.  
  141.   /* duplicate input string so that we can modify it */
  142.   s1 = strdup(input);
  143.   /* upcase string */
  144.   for (i = 0; s1[i]; i++)
  145.     if (islower(s1[i])) s1[i] = toupper(s1[i]);
  146.  
  147.   /* return a short name if possible, some vendor names are verbose */
  148.   if (StringSearch(s1, "DEC") ||
  149.       StringSearch(s1, "DECWINDOWS") ||
  150.       StringSearch(s1, "Digital Equipment Corporation") ||
  151.       StringSearch(s1, "DigitalEquipmentCorporation"))
  152.     s2 = strdup("DEC");
  153.   else if (StringSearch(s1, "SGI") ||
  154.        StringSearch(s1, "SILCON GRAPHICS"))
  155.     s2 = strdup("SGI");
  156.   else if (StringSearch(s1, "IBM") ||
  157.        StringSearch(s1, "INTERNATIONAL BUSINESS MACHINES"))
  158.     s2 = strdup("IBM");
  159.   else
  160.     s2 = strdup(s1);
  161.  
  162.   free(s1);
  163.   return(s2);
  164. }
  165.  
  166.  
  167. /******************************************************************************
  168.  *
  169.  * GetHostMemorySize - Return kilobytes of memory installed on host platform
  170.  *
  171.  * Description:
  172.  *  Returns the number of kilobytes of memory installed on host platform
  173.  *
  174.  * Returns:
  175.  *  kilobytes of host platform memory
  176.  *
  177.  * Side Effects:
  178.  *  None
  179.  *
  180.  * Errors:
  181.  *  return 0 if unable to determine memory configuration
  182.  *
  183.  * Revision History:
  184.  *  Revision 0: Author: John R. Dennis Date: Thu Aug  4 15:55:19 1994
  185.  *    Initial Release
  186.  *
  187.  *****************************************************************************/
  188. static int
  189. GetHostMemorySize(void)
  190. {
  191.   /* AvailMem */
  192.   return (24 * 1024 * 1024) / 1024;
  193. }
  194.  
  195.  
  196. /******************************************************************************
  197.  *
  198.  * GetHostVendor - return string naming the system vendor
  199.  *
  200.  * Description:
  201.  *  return the name of the system vendor as a string. This is to identify
  202.  *  manufacturer of the system. The string is allocated with malloc, it should
  203.  *  be freed when no longer in use.
  204.  *
  205.  * Returns:
  206.  *  pointer to allocated string
  207.  *
  208.  * Side Effects:
  209.  *  string allocation, string should be freed when no longer needed.
  210.  *
  211.  * Errors:
  212.  *  no errors, if function fails the string "unknown" is returned
  213.  *
  214.  * Revision History:
  215.  *  Revision 0: Author: John R. Dennis Date: Mon Aug  8 16:30:53 1994
  216.  *    Initial Release
  217.  *
  218.  *****************************************************************************/
  219. static char *
  220. GetHostVendor(void)
  221. {
  222.   /* See if it's a DEC system */
  223.   char *hostModel;
  224.  
  225.   hostModel = GetHostModel();
  226.   if ( strstr(hostModel,"DEC") == hostModel)
  227.   {
  228.     free(hostModel);
  229.     return(strdup("DEC"));
  230.   }
  231.   else
  232.   {
  233.     free(hostModel);
  234.     return(strdup("unknown"));
  235.   }
  236. }
  237.  
  238.  
  239. /******************************************************************************
  240.  *
  241.  * GetHostModel - return string naming the host model
  242.  *
  243.  * Description:
  244.  * return string identifying the host platform's model designation. The string
  245.  * is allocated with malloc, it should be freed when no longer in use.
  246.  *
  247.  * Returns:
  248.  *  pointer to allocated string
  249.  *
  250.  * Side Effects:
  251.  *  string allocation, string should be freed when no longer needed.
  252.  *
  253.  * Errors:
  254.  *  no errors, if function fails the string "unknown" is returned
  255.  *
  256.  * Revision History:
  257.  *  Revision 0: Author: John R. Dennis Date: Mon Aug  8 16:30:53 1994
  258.  *    Initial Release
  259.  *
  260.  *****************************************************************************/
  261. static char *
  262. GetHostModel(void)
  263. {
  264.   return strdup("AmigaOS");
  265. }
  266.  
  267.  
  268. /******************************************************************************
  269.  *
  270.  * GetHostCPU - return string naming the host CPU
  271.  *
  272.  * Description:
  273.  * return string identifying the host platform's CPU. The string
  274.  * is allocated with malloc, it should be freed when no longer in use.
  275.  *
  276.  * Returns:
  277.  *  pointer to allocated string
  278.  *
  279.  * Side Effects:
  280.  *  string allocation, string should be freed when no longer needed.
  281.  *
  282.  * Errors:
  283.  *  no errors, if function fails the string "unknown" is returned
  284.  *
  285.  * Revision History:
  286.  *  Revision 0: Author: John R. Dennis Date: Mon Aug  8 16:30:53 1994
  287.  *    Initial Release
  288.  *
  289.  *****************************************************************************/
  290. static char *
  291. GetHostCPU(void)
  292. {
  293.   return strdup("Motorola MC68030 (30MHz), MC68882 (30MHz)");
  294. }
  295.  
  296.  
  297. /******************************************************************************
  298.  *
  299.  * GetHostCPUCount - return string indicating number of host CPU's
  300.  *
  301.  * Description:
  302.  * return string indicating number of host CPU's. The string "unknown" is
  303.  * returned if the count is not determinable. The string is allocated with
  304.  * malloc, it should be freed when no longer in use.
  305.  *
  306.  * Returns:
  307.  *  pointer to allocated string
  308.  *
  309.  * Side Effects:
  310.  *  string allocation, string should be freed when no longer needed.
  311.  *
  312.  * Errors:
  313.  *  no errors, if function fails the string "unknown" is returned
  314.  *
  315.  * Revision History:
  316.  *  Revision 0: Author: John R. Dennis Date: Mon Feb 27 14:18:41 EST 1995
  317.  *    Initial Release
  318.  *
  319.  *****************************************************************************/
  320. static char *
  321. GetHostCPUCount(void)
  322. {
  323.   return(strdup("unknown"));
  324. }
  325.  
  326. /******************************************************************************
  327.  *
  328.  * GetHostPrimaryCacheSize - return string indicating host's primary cache (KB)
  329.  *
  330.  * Description:
  331.  * return string indicating the number of kilobytes of primary cache on the
  332.  * host's CPU, or "unknown" if not determinable. The string
  333.  * is allocated with malloc, it should be freed when no longer in use.
  334.  *
  335.  * Returns:
  336.  *  pointer to allocated string
  337.  *
  338.  * Side Effects:
  339.  *  string allocation, string should be freed when no longer needed.
  340.  *
  341.  * Errors:
  342.  *  no errors, if function fails the string "unknown" is returned
  343.  *
  344.  * Revision History:
  345.  *  Revision 0: Author: John R. Dennis Date: Mon Feb 27 14:18:41 EST 1995
  346.  *    Initial Release
  347.  *
  348.  *****************************************************************************/
  349. static char *
  350. GetHostPrimaryCacheSize(void)
  351. {
  352.   return(strdup("0 KB"));
  353. }
  354.  
  355. /******************************************************************************
  356.  *
  357.  * GetHostSecondaryCacheSize - return string indicating host's secondary cache (KB)
  358.  *
  359.  * Description:
  360.  * return string indicating the number of kilobytes of secondary cache on the
  361.  * host's CPU, or "unknown" if not determinable. The string
  362.  * is allocated with malloc, it should be freed when no longer in use.
  363.  *
  364.  * Returns:
  365.  *  pointer to allocated string
  366.  *
  367.  * Side Effects:
  368.  *  string allocation, string should be freed when no longer needed.
  369.  *
  370.  * Errors:
  371.  *  no errors, if function fails the string "unknown" is returned
  372.  *
  373.  * Revision History:
  374.  *  Revision 0: Author: John R. Dennis Date: Mon Feb 27 14:18:41 EST 1995
  375.  *    Initial Release
  376.  *
  377.  *****************************************************************************/
  378. static char *
  379. GetHostSecondaryCacheSize(void)
  380. {
  381.   return(strdup("0 KB"));
  382. }
  383.  
  384. /******************************************************************************
  385.  *
  386.  * GetWindowSystem - return string naming the windowing system
  387.  *
  388.  * Description:
  389.  * return string identifying the windowing system in use on the target
  390.  * device. The string is allocated with malloc, it should be freed when no
  391.  * longer in use.
  392.  *
  393.  * Returns:
  394.  *  pointer to allocated string
  395.  *
  396.  * Side Effects:
  397.  *  string allocation, string should be freed when no longer needed.
  398.  *
  399.  * Errors:
  400.  *  no errors, if function fails the string "unknown" is returned
  401.  *
  402.  * Revision History:
  403.  *  Revision 0: Author: John R. Dennis Date: Mon Aug  8 16:30:53 1994
  404.  *    Initial Release
  405.  *
  406.  *****************************************************************************/
  407. static char *
  408. GetWindowSystem(void)
  409. {
  410.   return(strdup("MesaGL"));
  411. }
  412.  
  413. /******************************************************************************
  414.  *
  415.  * GetDriverVersion - return string identifying the graphics driver
  416.  *
  417.  * Description:
  418.  * Return string identifying the graphics driver version. If there is no
  419.  * graphics driver than the string "NA" is returned. If a graphics driver
  420.  * exists, but the function cannot identify it then the string "unknown" is
  421.  * returned.  The string is allocated with malloc, it should be freed when no
  422.  * longer in use.
  423.  *
  424.  * Returns:
  425.  *  pointer to allocated string
  426.  *
  427.  * Side Effects:
  428.  *  string allocation, string should be freed when no longer needed.
  429.  *
  430.  * Errors:
  431.  *  no errors, if function fails the string "unknown" is returned
  432.  *
  433.  * Revision History:
  434.  *  Revision 0: Author: John R. Dennis Date: Mon Feb 27 15:00:18 EST 1995
  435.  *    Initial Release
  436.  *
  437.  *****************************************************************************/
  438. static char *
  439. GetDriverVersion(void)
  440. {
  441.   return(strdup("3.0"));
  442. }
  443.  
  444. /******************************************************************************
  445.  *
  446.  * GetHostOperatingSystem - return string naming the host CPU operating system
  447.  *
  448.  * Description:
  449.  *  return the type of the host operating system as a string. This is to
  450.  *  identify what type of operating system this program is running under. The
  451.  *  string is allocated with malloc, it should be freed when no longer in use.
  452.  *
  453.  * Returns:
  454.  *  pointer to allocated string
  455.  *
  456.  * Side Effects:
  457.  *  string allocation, string should be freed when no longer needed.
  458.  *
  459.  * Errors:
  460.  *  no errors, if function fails the string "unknown" is returned
  461.  *
  462.  * Revision History:
  463.  *  Revision 0: Author: John R. Dennis Date: Mon Aug  8 16:30:53 1994
  464.  *    Initial Release
  465.  *
  466.  *****************************************************************************/
  467. static char *
  468. GetHostOperatingSystem(void)
  469. {
  470.   return(strdup("AmigaOS 3.1"));
  471. }
  472.  
  473.  
  474. /******************************************************************************
  475.  *
  476.  * GetHostOperatingSystemRelease - return string naming operating system release
  477.  *
  478.  * Description:
  479.  *  return the release/version of the host operating system as a string. This
  480.  *  is to identify what version of the operating system this program is
  481.  *  running under. The string is allocated with malloc, it should be freed
  482.  *  when no longer in use.
  483.  *
  484.  * Returns:
  485.  *  pointer to allocated string
  486.  *
  487.  * Side Effects:
  488.  *  string allocation, string should be freed when no longer needed.
  489.  *
  490.  * Errors:
  491.  *  no errors, if function fails the string "unknown" is returned
  492.  *
  493.  * Revision History:
  494.  *  Revision 0: Author: John R. Dennis Date: Mon Aug  8 16:30:53 1994
  495.  *    Initial Release
  496.  *
  497.  *****************************************************************************/
  498. static char *
  499. GetHostOperatingSystemRelease(void)
  500. {
  501.   return(strdup("40.72"));
  502. }
  503.  
  504.  
  505. /******************************************************************************
  506.  *
  507.  * GetHostName - return string naming the host
  508.  *
  509.  * Description:
  510.  *  return the name of this host as a string. This is to identify which
  511.  *  platform this program is running on. The string is allocated with malloc,
  512.  *  it should be freed when no longer in use.
  513.  *
  514.  * Returns:
  515.  *  pointer to allocated string
  516.  *
  517.  * Side Effects:
  518.  *  string allocation, string should be freed when no longer needed.
  519.  *
  520.  * Errors:
  521.  *  no errors, if function fails the string "unknown" is returned
  522.  *
  523.  * Revision History:
  524.  *  Revision 0: Author: John R. Dennis Date: Mon Aug  8 16:30:53 1994
  525.  *    Initial Release
  526.  *
  527.  *****************************************************************************/
  528. static char *
  529. GetHostName(void)
  530. {
  531.   return(strdup("RamsesIII"));
  532. }
  533.  
  534.  
  535. /******************************************************************************
  536.  *
  537.  * GetDateTime - get the current month, day, year, hour, minute
  538.  *
  539.  * Description:
  540.  *  Get the current  day, month, year, hour, minute. Each is a pointer to an
  541.  *  integer. If the pointer is NULL then no value is returned for that
  542.  *  parameter, otherwise an assignment is made to the integer pointed to by
  543.  *  the parameter.
  544.  *
  545.  *  month:  in the range [1-12] 1=January, 12=December
  546.  *  day:    in the range [1-31]
  547.  *  year:   as a 4 digit number, e.g. 1994
  548.  *  hour:   in the range [0-23]
  549.  *  min:    in the range [0-59]
  550.  *
  551.  * Returns:
  552.  *  0 for success, error code otherwise
  553.  *
  554.  * Side Effects:
  555.  *  None
  556.  *
  557.  * Errors:
  558.  *  return non-zero on failure
  559.  *
  560.  * Revision History:
  561.  *  Revision 0: Author: John R. Dennis Date: Wed Aug 17 13:08:36 1994
  562.  *    Initial Release
  563.  *
  564.  *****************************************************************************/
  565.  
  566. int
  567. GetDateTime(int *month, int *day, int *year, int *hour, int *minute)
  568. {
  569.   time_t timeT;
  570.   struct tm *timeTm;
  571.  
  572.   time(&timeT);
  573.   timeTm = localtime(&timeT);
  574.   if (timeTm == NULL) {
  575.     fprintf(stderr, "Error calling localtime: %d\n", errno);
  576.     return(errno);
  577.   }
  578.   if (month)  *month  = timeTm->tm_mon + 1;
  579.   if (day)    *day    = timeTm->tm_mday;
  580.   if (year)   *year   = timeTm->tm_year + 1900;
  581.   if (hour)   *hour   = timeTm->tm_hour;
  582.   if (minute) *minute = timeTm->tm_min;
  583.   return(0);
  584. }
  585.  
  586.  
  587. /******************************************************************************
  588.  *
  589.  * GetOpenGLClientVendor - return string naming the client library vendor
  590.  *
  591.  * Description:
  592.  *  return the name of the vendor supplying the OpenGL client library.  The
  593.  *  string is allocated with malloc,it should be freed when no longer in use.
  594.  *
  595.  * Returns:
  596.  *  pointer to allocated string
  597.  *
  598.  * Side Effects:
  599.  *  string allocation, string should be freed when no longer needed.
  600.  *
  601.  * Errors:
  602.  *  no errors, if function fails the string "unknown" is returned
  603.  *
  604.  * Revision History:
  605.  *  Revision 0: Author: John R. Dennis Date: Mon Aug  8 16:30:53 1994
  606.  *    Initial Release
  607.  *
  608.  *****************************************************************************/
  609. static char *
  610. GetOpenGLClientVendor(void)
  611. {
  612.   char *pstr;
  613.   if (pstr = (char *)glGetString(GL_VENDOR))
  614.     return(GetShortVendorName(pstr));
  615.   else
  616.     return(strdup("unknown"));
  617. }
  618.  
  619.  
  620. /******************************************************************************
  621.  *
  622.  * GetOpenGLClientVersion - return string naming the client library version
  623.  *
  624.  * Description:
  625.  *  return the version of the OpenGL client library.  The string is allocated
  626.  *  with malloc,it should be freed when no longer in use.
  627.  *
  628.  * Returns:
  629.  *  pointer to allocated string
  630.  *
  631.  * Side Effects:
  632.  *  string allocation, string should be freed when no longer needed.
  633.  *
  634.  * Errors:
  635.  *  no errors, if function fails the string "unknown" is returned
  636.  *
  637.  * Revision History:
  638.  *  Revision 0: Author: John R. Dennis Date: Mon Aug  8 16:30:53 1994
  639.  *    Initial Release
  640.  *
  641.  *****************************************************************************/
  642. static char *
  643. GetOpenGLClientVersion(void)
  644. {
  645.   char *pstr;
  646.   if (pstr = (char *)glGetString(GL_VERSION))
  647.     return(strdup(pstr));
  648.   else
  649.     return(strdup("unknown"));
  650. }
  651.  
  652.  
  653. /******************************************************************************
  654.  *
  655.  * GetOpenGLClientExtensions - return string naming the client extensions
  656.  *
  657.  * Description:
  658.  *  return the extensions supported in the OpenGL client library.  The string
  659.  *  is allocated with malloc,it should be freed when no longer in use.
  660.  *
  661.  * Returns:
  662.  *  pointer to allocated string
  663.  *
  664.  * Side Effects:
  665.  *  string allocation, string should be freed when no longer needed.
  666.  *
  667.  * Errors:
  668.  *  no errors, if function fails the string "unknown" is returned
  669.  *
  670.  * Revision History:
  671.  *  Revision 0: Author: John R. Dennis Date: Mon Aug  8 16:30:53 1994
  672.  *    Initial Release
  673.  *
  674.  *****************************************************************************/
  675. static char *
  676. GetOpenGLClientExtensions(void)
  677. {
  678.   char *pstr;
  679.   if (pstr = (char *)glGetString(GL_EXTENSIONS))
  680.     return(strdup(pstr));
  681.   else
  682.     return(strdup("unknown"));
  683. }
  684.  
  685.  
  686.  
  687. /******************************************************************************
  688.  *
  689.  * GetEnvironment - return info about environment test was run in
  690.  *
  691.  * Description:
  692.  *  This function fills in an environment info record with every pertinent
  693.  *  piece of information about the condiditons under which the test was run.
  694.  *
  695.  * Returns:
  696.  *  0 success, error code otherwise
  697.  *
  698.  * Side Effects:
  699.  *  None
  700.  *
  701.  * Errors:
  702.  *  errors generally only with bad configurations, too many to list
  703.  *
  704.  * Revision History:
  705.  *  Revision 0: Author: John R. Dennis Date: Thu Aug 18 16:52:35 1994
  706.  *    Initial Release
  707.  *
  708.  *****************************************************************************/
  709.  
  710. #include <intuition/intuition.h>
  711. #include <intuition/screens.h>
  712. #include <gl/amigamesa.h>
  713.  
  714. void
  715. GetAOSEnvironment(EnvironmentInfo *info) {
  716.   struct amigamesa_context *amesa;
  717.   
  718.   if(!(amesa = auxAOSContext()))
  719.     return;
  720.   
  721.   info->windowWidth = amesa->window->GZZWidth;
  722.   info->windowHeight = amesa->window->GZZHeight;
  723.   info->screenWidth = amesa->Screen->Width;
  724.   info->screenHeight = amesa->Screen->Height;
  725.   
  726.   info->bufConfig.doubleBuffer = amesa->visual->db_flag;
  727.   info->bufConfig.stereo = -1;
  728.   if(!(info->bufConfig.rgba = amesa->visual->rgb_flag)) {
  729.     info->bufConfig.indexSize = amesa->visual->depth;
  730.  
  731.     info->bufConfig.redSize = -1;
  732.     info->bufConfig.greenSize = -1;
  733.     info->bufConfig.blueSize = -1;
  734.     info->bufConfig.alphaSize = -1;
  735.     info->bufConfig.accumRedSize = -1;
  736.     info->bufConfig.accumGreenSize = -1;
  737.     info->bufConfig.accumBlueSize = -1;
  738.     info->bufConfig.accumAlphaSize = -1;
  739.   }
  740.   else {
  741.     info->bufConfig.indexSize = -1;
  742.  
  743.     info->bufConfig.redSize = amesa->visual->gl_visual->RedBits;
  744.     info->bufConfig.greenSize = amesa->visual->gl_visual->GreenBits;
  745.     info->bufConfig.blueSize = amesa->visual->gl_visual->BlueBits;
  746.     info->bufConfig.alphaSize = amesa->visual->gl_visual->AlphaBits;
  747.     info->bufConfig.accumRedSize = amesa->visual->gl_visual->AccumBits;
  748.     info->bufConfig.accumGreenSize = amesa->visual->gl_visual->AccumBits;
  749.     info->bufConfig.accumBlueSize = amesa->visual->gl_visual->AccumBits;
  750.     info->bufConfig.accumAlphaSize = amesa->visual->gl_visual->AccumBits;
  751.   }
  752.  
  753.   info->bufConfig.depthSize = amesa->visual->gl_visual->DepthBits;
  754.   info->bufConfig.stencilSize = amesa->visual->gl_visual->StencilBits;
  755.  
  756.   info->bufConfig.auxBuffers = 0;
  757. }
  758.  
  759. int
  760. GetEnvironment(EnvironmentInfo *info)
  761. {
  762.   GLenum windType;
  763.  
  764.   FreeEnvironmentData(info);
  765.  
  766.   GetDateTime(&info->month, &info->day, &info->year, NULL, NULL);
  767.   info->host = GetHostName();
  768.   info->hostOperatingSystem = GetHostOperatingSystem();
  769.   info->hostOperatingSystemVersion = GetHostOperatingSystemRelease();
  770.   info->hostVendor = GetHostVendor();
  771.   info->hostModel = GetHostModel();
  772.   info->hostCPU = GetHostCPU();
  773.   info->hostCPUCount = GetHostCPUCount();
  774.   info->hostPrimaryCacheSize = GetHostPrimaryCacheSize();
  775.   info->hostSecondaryCacheSize = GetHostSecondaryCacheSize();
  776.   info->windowSystem = GetWindowSystem();
  777.   info->driverVersion = GetDriverVersion();
  778.   info->hostMemorySize = GetHostMemorySize() / 1024; /* kilobytes to MB */
  779.   info->glVendor = GetShortVendorName((char *)glGetString(GL_VENDOR));
  780.   info->glVersion = strdup((char *)glGetString(GL_VERSION));
  781.   info->glRenderer = strdup((char *)glGetString(GL_RENDERER));
  782.   info->glExtensions = strdup((char *)glGetString(GL_EXTENSIONS));
  783.   info->glClientVendor = GetOpenGLClientVendor();
  784.   info->glClientVersion = GetOpenGLClientVersion();
  785.   info->glClientExtensions = GetOpenGLClientExtensions();
  786.  
  787. #ifdef GLU_VERSION_1_1
  788.   info->gluVersion = strdup((char *)gluGetString(GLU_VERSION));;
  789.   info->gluExtensions = strdup((char *)gluGetString(GLU_EXTENSIONS));;
  790. #else
  791.   info->gluVersion = strdup("unknown");
  792.   info->gluExtensions = strdup("unknown");
  793. #endif
  794.  
  795.   GetAOSEnvironment(info);
  796.  
  797. #if defined(WIN32)
  798.   /*
  799.    * There is no direct rendering at this time.
  800.    */
  801.   info->directRender = FALSE;
  802. #else
  803.   /*
  804.    * Direct rendering is a "request", not a guarantee. We need to check the
  805.    * direct render bit for each test because the GL context is only set up
  806.    * in the above conditional block. If we didn't check it for each test
  807.    * then the value for direct rendering store in the test descriptor would
  808.    * be the "request" value, not the actual value.
  809.    */
  810.  
  811.   windType = auxGetDisplayMode();
  812.   if (windType & AUX_DIRECT)
  813.     info->directRender = TRUE;
  814.   else
  815.     info->directRender = FALSE;
  816. #endif
  817.  
  818.     return (0);
  819. }
  820.  
  821.  
  822.  
  823. /******************************************************************************
  824.  *
  825.  * FreeEnvironmentData - frees all dynamic data in EnvironmentInfo struct
  826.  *
  827.  * Description:
  828.  *  Free all the dynamically allocated data in an EnvironmentInfo struct. Each
  829.  *  pointer in the struct is assigned the value of NULL after its data has
  830.  *  been freed. The struct itself is not freed.
  831.  *
  832.  * Returns:
  833.  *  void
  834.  *
  835.  * Side Effects:
  836.  *  free dynamically allocated memory
  837.  *
  838.  * Errors:
  839.  *  None
  840.  *
  841.  * Revision History:
  842.  *  Revision 0: Author: John R. Dennis Date: Tue Sep 13 17:31:19 1994
  843.  *    Initial Release
  844.  *
  845.  *****************************************************************************/
  846.  
  847. void
  848. FreeEnvironmentData(EnvironmentInfo *info)
  849. {
  850.   if (info->host != NULL) free(info->host);
  851.   if (info->hostOperatingSystem != NULL) free(info->hostOperatingSystem);
  852.   if (info->hostOperatingSystemVersion != NULL) free(info->hostOperatingSystemVersion);
  853.   if (info->hostVendor != NULL) free(info->hostVendor);
  854.   if (info->hostModel != NULL) free(info->hostModel);
  855.   if (info->hostCPU != NULL) free(info->hostCPU);
  856.   if (info->hostCPUCount != NULL) free(info->hostCPUCount);
  857.   if (info->hostPrimaryCacheSize != NULL) free(info->hostPrimaryCacheSize);
  858.   if (info->hostSecondaryCacheSize != NULL) free(info->hostSecondaryCacheSize);
  859.   if (info->windowSystem != NULL) free(info->windowSystem);
  860.   if (info->driverVersion != NULL) free(info->driverVersion);
  861.   if (info->glVendor != NULL) free(info->glVendor);
  862.   if (info->glVersion != NULL) free(info->glVersion);
  863.   if (info->glRenderer != NULL) free(info->glRenderer);
  864.   if (info->glExtensions != NULL) free(info->glExtensions);
  865.   if (info->glClientVendor != NULL) free(info->glClientVendor);
  866.   if (info->glClientVersion != NULL) free(info->glClientVersion);
  867.   if (info->glClientExtensions != NULL) free(info->glClientExtensions);
  868.   if (info->gluVersion != NULL) free(info->gluVersion);
  869.   if (info->gluExtensions != NULL) free(info->gluExtensions);
  870.   NullEnvironmentData(info);
  871. }
  872.  
  873.  
  874. /******************************************************************************
  875.  *
  876.  * NullEnvironmentData - sets all dynamic data ptrs in EnvironmentInfo to NULL
  877.  *
  878.  * Description:
  879.  *  Sets all the pointers to dynamically allocated data in an EnvironmentInfo
  880.  *  struct to NULL. The data pointed to by the pointers are not freed, use the
  881.  *  function FreeEnvironmentData for that purpose.
  882.  *
  883.  * Returns:
  884.  *  void
  885.  *
  886.  * Side Effects:
  887.  *  None
  888.  *
  889.  * Errors:
  890.  *  None
  891.  *
  892.  * Revision History:
  893.  *  Revision 0: Author: John R. Dennis Date: Tue Sep 13 17:31:19 1994
  894.  *    Initial Release
  895.  *
  896.  *****************************************************************************/
  897.  
  898. void
  899. NullEnvironmentData(EnvironmentInfo *info)
  900. {
  901.     info->host = NULL;
  902.     info->hostOperatingSystem = NULL;
  903.     info->hostOperatingSystemVersion = NULL;
  904.     info->hostVendor = NULL;
  905.     info->hostModel = NULL;
  906.     info->hostCPU = NULL;
  907.     info->hostCPUCount = NULL;
  908.     info->hostPrimaryCacheSize = NULL;
  909.     info->hostSecondaryCacheSize = NULL;
  910.     info->windowSystem = NULL;
  911.     info->driverVersion = NULL;
  912.     info->glVendor = NULL;
  913.     info->glVersion = NULL;
  914.     info->glRenderer = NULL;
  915.     info->glExtensions = NULL;
  916.     info->glClientVendor = NULL;
  917.     info->glClientVersion = NULL;
  918.     info->glClientExtensions = NULL;
  919.     info->gluVersion = NULL;
  920.     info->gluExtensions = NULL;
  921. }
  922.  
  923.  
  924.  
  925. /******************************************************************************
  926.  *
  927.  * PrintEnvironment - print contents of EnvironmentInfo struct
  928.  *
  929.  * Description:
  930.  *  Print the contents of EnvironmentInfo struct. The stream parameter Points
  931.  *  to a FILE structure specifying an open stream to which output will be
  932.  *  written. The title parameter is a pointer to a string which will be output
  933.  *  before any of the EnvironmentInfo data is output, The title string may be
  934.  *  NULL in which case no title string will be written. The leader parameter
  935.  *  is a pointer to a string which will be output before each field in the
  936.  *  EnvironmentInfo struct. The nameWidth parameter is an integer parameter
  937.  *  specifying how pad the name of each field. This can be used to cause the
  938.  *  values to line up in a column. A positive value left justifies, a negative
  939.  *  value right justifies. The suffix parameter is a pointer to a string which
  940.  *  will be output after all of the EnvironmentInfo data is output, The suffix
  941.  *  string may be NULL in which case no suffix string will be written.
  942.  *
  943.  * Returns:
  944.  *  void
  945.  *
  946.  * Side Effects:
  947.  *  file stream output
  948.  *
  949.  * Errors:
  950.  *  None
  951.  *
  952.  * Revision History:
  953.  *  Revision 0: Author: John R. Dennis Date: Wed Sep 14 09:02:57 1994
  954.  *    Initial Release
  955.  *
  956.  *****************************************************************************/
  957.  
  958. void
  959. PrintEnvironment(FILE *stream, EnvironmentInfo *info, char *title,
  960.                  char *leader, int nameWidth, char *suffix)
  961. {
  962.   if (title) fprintf(stream, "%s", title);
  963.  
  964.   fprintf(stream, "%s%*s%d\n", leader, nameWidth,
  965.          "Month", info->month);
  966.   fprintf(stream, "%s%*s%d\n", leader, nameWidth,
  967.          "Day", info->day);
  968.   fprintf(stream, "%s%*s%d\n", leader, nameWidth,
  969.          "Year", info->year);
  970.   fprintf(stream, "%s%*s%s\n", leader, nameWidth,
  971.          "Host", info->host);
  972.   fprintf(stream, "%s%*s%s\n", leader, nameWidth,
  973.          "Operating System", info->hostOperatingSystem);
  974.   fprintf(stream, "%s%*s%s\n", leader, nameWidth,
  975.          "Operating System Version", info->hostOperatingSystemVersion);
  976.   fprintf(stream, "%s%*s%s\n", leader, nameWidth,
  977.          "Host Vendor", info->hostVendor);
  978.   fprintf(stream, "%s%*s%s\n", leader, nameWidth,
  979.          "Host Model", info->hostModel);
  980.   fprintf(stream, "%s%*s%s\n", leader, nameWidth,
  981.          "Host CPU", info->hostCPU);
  982.   fprintf(stream, "%s%*s%s\n", leader, nameWidth,
  983.          "Host CPU Count", info->hostCPUCount);
  984.   fprintf(stream, "%s%*s%d\n", leader, nameWidth,
  985.          "Host Memory Size (MB)", info->hostMemorySize);
  986.   fprintf(stream, "%s%*s%s\n", leader, nameWidth,
  987.          "Host Primary Cache Size (KB)", info->hostPrimaryCacheSize);
  988.   fprintf(stream, "%s%*s%s\n", leader, nameWidth,
  989.          "Host Secondary Cache Size (KB)", info->hostSecondaryCacheSize);
  990.   fprintf(stream, "%s%*s%s\n", leader, nameWidth,
  991.          "Window System", info->windowSystem);
  992.   fprintf(stream, "%s%*s%s\n", leader, nameWidth,
  993.           "Driver Version", info->driverVersion);
  994.   fprintf(stream, "%s%*s%s\n", leader, nameWidth,
  995.          "OpenGL Vendor", info->glVendor);
  996.   fprintf(stream, "%s%*s%s\n", leader, nameWidth,
  997.          "OpenGL Version", info->glVersion);
  998.   fprintf(stream, "%s%*s%s\n", leader, nameWidth,
  999.          "OpenGL Extensions", info->glExtensions);
  1000.   fprintf(stream, "%s%*s%s\n", leader, nameWidth,
  1001.          "OpenGL Renderer", info->glRenderer);
  1002.   fprintf(stream, "%s%*s%s\n", leader, nameWidth,
  1003.          "OpenGL Client Vendor", info->glClientVendor);
  1004.   fprintf(stream, "%s%*s%s\n", leader, nameWidth,
  1005.          "OpenGL Client Version", info->glClientVersion);
  1006.   fprintf(stream, "%s%*s%s\n", leader, nameWidth,
  1007.          "OpenGL Client Extensions", info->glClientExtensions);
  1008.   fprintf(stream, "%s%*s%s\n", leader, nameWidth,
  1009.          "GLU Version", info->gluVersion);
  1010.   fprintf(stream, "%s%*s%s\n", leader, nameWidth,
  1011.          "GLU Extensions", info->gluExtensions);
  1012.   fprintf(stream, "%s%*s%s\n", leader, nameWidth,
  1013.          "Direct Rendering", info->directRender ? "True" : "False");
  1014.   fprintf(stream, "%s%*s%s\n", leader, nameWidth,
  1015.          "Double Buffer", info->bufConfig.doubleBuffer ? "True" : "False");
  1016.   fprintf(stream, "%s%*s%s\n", leader, nameWidth,
  1017.          "Stereo", info->bufConfig.stereo ? "True" : "False");
  1018.   fprintf(stream, "%s%*s%s\n", leader, nameWidth,
  1019.          "RGBA", info->bufConfig.rgba ? "True" : "False");
  1020.   fprintf(stream, "%s%*s%d\n", leader, nameWidth,
  1021.          "Color Index Size", info->bufConfig.indexSize);
  1022.   fprintf(stream, "%s%*s%d\n", leader, nameWidth,
  1023.          "Red Size", info->bufConfig.redSize);
  1024.   fprintf(stream, "%s%*s%d\n", leader, nameWidth,
  1025.          "Green Size", info->bufConfig.greenSize);
  1026.   fprintf(stream, "%s%*s%d\n", leader, nameWidth,
  1027.          "Blue Size", info->bufConfig.blueSize);
  1028.   fprintf(stream, "%s%*s%d\n", leader, nameWidth,
  1029.          "Alpha Size", info->bufConfig.alphaSize);
  1030.   fprintf(stream, "%s%*s%d\n", leader, nameWidth,
  1031.          "Accum Red Size", info->bufConfig.accumRedSize);
  1032.   fprintf(stream, "%s%*s%d\n", leader, nameWidth,
  1033.          "Accum Green Size", info->bufConfig.accumGreenSize);
  1034.   fprintf(stream, "%s%*s%d\n", leader, nameWidth,
  1035.          "Accum Blue Size", info->bufConfig.accumBlueSize);
  1036.   fprintf(stream, "%s%*s%d\n", leader, nameWidth,
  1037.          "Accum Alpha Size", info->bufConfig.accumAlphaSize);
  1038.   fprintf(stream, "%s%*s%d\n", leader, nameWidth,
  1039.          "Depth Size", info->bufConfig.depthSize);
  1040.   fprintf(stream, "%s%*s%d\n", leader, nameWidth,
  1041.          "Stencil Size", info->bufConfig.stencilSize);
  1042.   fprintf(stream, "%s%*s%d\n", leader, nameWidth,
  1043.          "Auxiliary Buffer Count", info->bufConfig.auxBuffers);
  1044.   fprintf(stream, "%s%*s%d\n", leader, nameWidth,
  1045.          "Frame BufferLevel", info->bufConfig.level);
  1046.   fprintf(stream, "%s%*s%d\n", leader, nameWidth,
  1047.          "Window Width (pixels)", info->windowWidth);
  1048.   fprintf(stream, "%s%*s%d\n", leader, nameWidth,
  1049.          "Window Height (pixels)", info->windowHeight);
  1050.   fprintf(stream, "%s%*s%d\n", leader, nameWidth,
  1051.          "Screen Width (pixels)", info->screenWidth);
  1052.   fprintf(stream, "%s%*s%d\n", leader, nameWidth,
  1053.          "Screen Height (pixels)", info->screenHeight);
  1054.   if (suffix) fprintf(stream, "%s", suffix);
  1055. }
  1056.  
  1057.